20e6273af5ecebb057d3bfc2b37ae97111f1e2bd,org.eclipse.dawnsci.hdf5/src/org/eclipse/dawnsci/hdf5/HDF5Utils.java,HDF5Utils,readDataset,#HDF5File#String#number[]#number[]#number[]#number#number#boolean#,393
Before Change
throw new NexusException("Out Of Memory", err);
}
// long msid = H5.H5Screate_simple(1, new long[] {length}, null);
long msid = H5.H5Screate_simple(rank, dsize, null);
H5.H5Sselect_all(msid);
PositionIterator it = data.getPositionIterator(axes);
After Change
}
if (schunk == null || all) {
if (rank == 0) {
msid = H5.H5Screate(HDF5Constants.H5S_SCALAR);
} else {
H5.H5Sselect_hyperslab(sid, HDF5Constants.H5S_SELECT_SET, sstart, sstride, dsize, null);
// long length = 1;
// for (int i = 0; i < rank; i++)
// length *= count[i];
//
// msid = H5.H5Screate_simple(1, new long[] {length}, null);
msid = H5.H5Screate_simple(rank, dsize, null);
H5.H5Sselect_all(msid);
}
data = DatasetFactory.zeros(lisize, count, ldtype);
Object odata = data.getBuffer();
boolean isREF = H5.H5Tequal(tid, HDF5Constants.H5T_STD_REF_OBJ);
if (isVLEN) {
H5.H5Dread_VLStrings(did, tid, msid, sid, HDF5Constants.H5P_DEFAULT, (Object[]) odata);
} else {
H5.H5Dread(did, tid, msid, sid, HDF5Constants.H5P_DEFAULT, odata);
if (odata instanceof byte[] && ldtype != Dataset.INT8) {
// TODO check if this is actually used
Object idata = null;
byte[] bdata = (byte[]) odata;
if (isText) {
idata = hdf.object.Dataset.byteToString(bdata, (int) H5.H5Tget_size(tid));
} else if (isREF) {
idata = HDFNativeData.byteToLong(bdata);
}
if (idata != null) {
data = createDataset(idata, count, ldtype, false); // extend later, if necessary
}
}
}
} else {
// read in many split chunks
final boolean[] isSplit = new boolean[rank];
final long[] send = new long[rank];
int length = 1;
for (int i = 0; i < rank; i++) {
send[i] = sstart[i] + count[i] * step[i];
isSplit[i] = schunk[i] <= 1 && dsize[i] > 1;
if (isSplit[i]) {
dsize[i] = 1;
} else {
length *= dsize[i];
}
}
if (length == 1) { // if just single point then bulk up request
for (int i = rank - 1; i >= 0; i--) {
int l = count[i];
if (l > 1) {
dsize[i] = l;
length = l;
isSplit[i] = false;
break;
}
}
}
final List<Integer> notSplit = new ArrayList<Integer>();
for (int i = 0; i < rank; i++) {
if (!isSplit[i])
notSplit.add(i);
}
final int[] axes = new int[notSplit.size()];
for (int i = 0; i < axes.length; i++) {
axes[i] = notSplit.get(i);
}
data = DatasetFactory.zeros(count, ldtype);
Object odata;
try {
odata = H5Datatype.allocateArray(tid, length);
} catch (OutOfMemoryError err) {
logger.error("Out of memory", err);
throw new NexusException("Out Of Memory", err);
}
// msid = H5.H5Screate_simple(1, new long[] {length}, null);
msid = H5.H5Screate_simple(rank, dsize, null);
H5.H5Sselect_all(msid);
PositionIterator it = data.getPositionIterator(axes);